<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
        <title>Document</title>
        <style>
            #div1{width: 200px; height: 200px; padding: 50px; background-color: lightgray; border: 1px solid black; margin: 100px auto}
            #word{width: 200px; height: 30px; font-size: 18px;}
            #desc{width: 200px; height: 150px; margin-top: 20px; background-color: lightgreen}
        </style>
        <script src = 'demo.js'></script>
        <script>
            //1、将字符串通过换行进行字符串分割
            var arr = word.split("\n");
            
            let map = new Map();

            for(var i = 0; i < arr.length - 1; i += 2){
                map.set(arr[i].substring(1), arr[i + 1].substring(6));
            }
            
            window.onload = function(){
                var oWord = document.getElementById("word");
                var oDesc = document.getElementById("desc");

                oWord.onkeyup = function(){
                    var value = map.get(this.value);
                    if(value){
                        oDesc.innerHTML = value;
                    }else{
                        oDesc.innerHTML = "查无此词";
                    }
                    
                }

            }
        </script>
    </head>
    <body>
        <div id = "div1">
            <input id = 'word' type="text" placeholder="输入英文单词"/>
            <div id = 'desc'></div>
        </div>
    </body>
</html>